from django import forms

from web import models
from web.forms.bootstrap import BootStrapForm


class WikiModelForm(BootStrapForm, forms.ModelForm):
    class Meta:
        model = models.Wiki
        exclude = ['project', 'depth', ]

    def __init__(self, request, *args, **kwargs):
        super().__init__(*args, **kwargs)
        data_list = [("", '请选择')]
        data_list.extend(models.Wiki.objects.filter(project=request.tracer.project).values_list('id', 'title'))
        self.fields['parent'].choices = data_list
